
//游戏主要部分
function qp_m() {
    //step：增加六种不同的颜色
    var a = [];
    a.push(COLOR_RED);
    a.push(COLOR_YELLOW);
    a.push(COLOR_GREEN);
    a.push(COLOR_PURPLE);
    a.push(COLOR_BLUE);
    a.push(COLOR_PINK);

    //step
    qp_k = new Qp_n(a);
    qp_k.randomMap();
    stage.removeChild(qp_j);

    //step:增加画布
    qp_j = new createjs.Container;
    stage.addChild(qp_j);

    //step:增加背景
    a = new createjs.Bitmap(queue.getResult("bg"));
    qp_j.addChild(a);

    //step
    qp_o();

    //step:步数的位置
    qp_i = new StepBoard("step", "#000000");
    qp_i.x = 450;
    qp_i.y = 20;
    stage.addChild(qp_i);

    //step
    qp_k.initfirstflood();
    qp_k.flood(qp_k.m_allitems[0].color, true);
    qp_i.reSet();

    //step10:不同的按钮
    //step10-1:红色按钮
    a = new createjs.Bitmap(queue.getResult("redbtn"));
    a.regX = 47;
    a.regY = 47;
    a.x = 62;
    a.y = 880;
    qp_j.addChild(a);
    a.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_RED), true == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
    }, a);
    a.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
    }, a);

    //step10-2:黄色按钮
    a = new createjs.Bitmap(queue.getResult("yellowbtn"));
    a.regX = 47;
    a.regY = 47;
    a.x = 165;
    a.y = 880;
    qp_j.addChild(a);
    a.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_YELLOW), true == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
    }, a);
    a.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
    }, a);

    //step10-3:紫色按钮
    a = new createjs.Bitmap(queue.getResult("purplebtn"));
    a.regX = 47;
    a.regY = 47;
    a.x = 268;
    a.y = 880;
    qp_j.addChild(a);
    a.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_PURPLE), true == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
    }, a);
    a.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
    }, a);

    //step10-4:蓝色按钮
    a = new createjs.Bitmap(queue.getResult("bluebtn"));
    a.regX = 47;
    a.regY = 47;
    a.x = 371;
    a.y = 880;
    qp_j.addChild(a);
    a.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_BLUE), true == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
    }, a);
    a.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
    }, a);

    //step10-5:绿色按钮
    a = new createjs.Bitmap(queue.getResult("greenbtn"));
    a.regX = 47;
    a.regY = 47;
    a.x = 474;
    a.y = 880;
    qp_j.addChild(a);
    a.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_GREEN), true == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
    }, a);
    a.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
    }, a);

    //step10-6:粉色按钮
    a = new createjs.Bitmap(queue.getResult("pinkbtn"));
    a.regX = 47;
    a.regY = 47;
    a.x = 577;
    a.y = 880;
    qp_j.addChild(a);
    a.on("mousedown", function (a) {
        IS_TOUCH && a.nativeEvent instanceof MouseEvent || (this.scaleY = this.scaleX = 0.95, qp_k.flood(COLOR_PINK), true == qp_k.isGameOver() && new GameoverNormal("#8de9cb", "#000000", qp_m, stage));
    }, a);
    a.on("pressup", function (a) {
        this.scaleY = this.scaleX = 1;
    }, a);
}

function qp_o() {
    qp_r(qp_k.m_allitems);
}

function qp_q(a, b, c) {
    for (var d = 0; d < a.length; d++) {
        qp_k.m_changeditems.push(a[d]);
    }
    for (d = 0; d < qp_k.m_changeditems.length; d++) {
        a = (qp_k.m_changeditems[d].indexj + qp_k.m_changeditems[d].indexi + 1) * qp_c, createjs.Tween.get(qp_k.m_changeditems[d].img).to({alpha: 1}, a).call(function () {
            this.graphics.clear();
            this.graphics.f(b).r(0, 0, qp_f, qp_f);
        }).to({alpha: 1}, 0);
    }
    true != c && qp_s(b);
}

function qp_r(a) {
    for (a = 0; a < qp_b; a++) {
        for (var b = 0; b < qp_a; b++) {
            var c = (a + b + 1) * qp_c, d = qp_k.m_allitems[a * qp_a + b].img;
            d.alpha = 0;
            createjs.Tween.get(d).to({alpha: 0}, c).to({alpha: 1}, 100);
            d.x = qp_d + (qp_f + qp_g) * b + qp_f / 2 + qp_h - b;
            d.y = qp_e + (qp_f + qp_g) * a + qp_f / 2 + qp_h - a;
            qp_j.addChild(d);
        }
    }
}

function qp_s(a) {
    a == COLOR_RED && createjs.Sound.play("do", true);
    a == COLOR_YELLOW && createjs.Sound.play("re", true);
    a == COLOR_PURPLE && createjs.Sound.play("mi", true);
    a == COLOR_BLUE && createjs.Sound.play("fa", true);
    a == COLOR_GREEN && createjs.Sound.play("so", true);
    a == COLOR_PINK && createjs.Sound.play("la", true);
}


